package GUI;

import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.Border;

public class MassagePanel extends JPanel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static JTextArea messagesText ;
	JPanel panel;
	
	JPanel MassagePanelConstr(JPanel pan){
		panel=pan;
		
		messagesText = new JTextArea();
		Border border = BorderFactory.createRaisedBevelBorder();
		Border borderTextArea =BorderFactory.createTitledBorder(border, "");
		messagesText.setBorder(borderTextArea);
		
		Border borderScroll = BorderFactory.createLoweredBevelBorder();
		Border borderScrollfact =BorderFactory.createTitledBorder(borderScroll, "Messages :");
		JScrollPane scrolltxt = new JScrollPane(messagesText);
		scrolltxt.setBorder(borderScrollfact);
		scrolltxt.setBounds(20, 420, 950, 200);
		panel.add(scrolltxt);
		
		return panel;
		
	}
	
	public static void writeMessagePanel(String text){
		Date date = new Date();
		messagesText.append(date.toString()+" : "+text+"\n");
		
	}
	public static void clearMessagesPanel(){
		messagesText.setText("");
		Date date = new Date();
		messagesText.append(date.toString()+" : Clear the messages\n");
		
	}
	
}
